<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\User;
use Illuminate\Support\Facades\Hash;

class AdminUserSeeder extends Seeder
{
    public function run()
    {
        // 检查是否已存在管理员用户
        $admin = User::where('email', 'admin@example.com')->first();
        
        if (!$admin) {
            // 创建管理员用户
            User::create([
                'name' => 'Admin',
                'email' => 'admin@example.com',
                'password' => Hash::make('admin123'),
                'is_admin' => true,
                'email_verified_at' => now(),
            ]);
            
            echo "管理员用户创建成功！\n";
            echo "用户名: admin@example.com\n";
            echo "密码: admin123\n";
        } else {
            echo "管理员用户已存在！\n";
            echo "用户名: " . $admin->email . "\n";
        }
    }
}
